from selenium import webdriver
from PIL import Image
import io
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

def get_fail(tip_png):

    # 使用Pillow处理图片
    image = Image.open("tip_png.png")


    # 计算验证码图片的位置
    left = 1240
    top = 550
    bottom = 650
    right = 1530

    print(left, top, right, bottom)

    # 裁剪验证码图片
    image = image.crop((left, top, right, bottom))

    # 保存验证码图片
    image.save('fail.png')

if __name__ == '__main__':
    get_fail('tip_png.png')